<?php
include($folder.'/layouts/code-behind/backend.php');
function blc_szinek_select($from, $itemsPerPage, $sortColumn, $sortDirection)
{
	$orderBy = $sortColumn.'_'.$sortDirection;
	return query('
		SELECT 
			c.id	  AS id,
			c.red     AS red, 
			c.green   AS green, 
			c.blue    AS blue,
			c.name    AS name
		FROM color c
		ORDER BY
			CASE WHEN :orderBy = \'name_asc\' THEN name END ASC,
			CASE WHEN :orderBy = \'name_desc\' THEN name END DESC
		LIMIT :from,:itemsPerPage',
		array('orderBy'=>$orderBy, 'from'=>$from, 'itemsPerPage'=>$itemsPerPage));
}
function blc_szinek_select_count()
{
	return queryScalar('SELECT COUNT(1) FROM color c', null);
}
$content['itemsPerPage'] = 4
?>